import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeMain from '../views/Home/main'

// 导入home的路由
import HomeRoute from '../views/Home/router'

// 导入type的路由
import TypeRoute from '../views/Type/router'

// my的路由
import MyRoute from '../views/My/router'

// 购物车的路由
import CartRoute from '../views/Cart/router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'HomeMain',
    component: HomeMain,
    redirect:'/index',
    children:[
      ...HomeRoute
    ]
  },
  {
    path: '/Type',
    name: 'TypesMain',
    redirect:'/Type/index',
    // 默认渲染
    component: () => import( '../views/Type/main'),
    children:[
      ...TypeRoute
    ]
  },
  {
    path: '/My',
    name: 'MyMain',
    redirect:'/My/index',
    // 默认渲染
    component: () => import( '../views/My/main'),
    children:[
      ...MyRoute
    ]
  },
  {
    path: '/Cart',
    name: 'CartMain',
    redirect:'/Cart/index',
    // 默认渲染
    component: () => import( '../views/Cart/main'),
    children:[
      ...CartRoute
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
